﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:ctrl="clr-namespace:MediaOwl.Common.ControlTemplates;assembly=MediaOwl.Common"
             x:Class="MediaOwl.LastFm.Views.MusicArtistSingleView"
             mc:Ignorable="d"
             d:DesignHeight="415"
             d:DesignWidth="595">
    <UserControl.Resources>

        <DataTemplate x:Key="CompactItemTemplate">
            <Grid Width="90">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="50"
                           Height="50"
                           Margin="10,0" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}"
                           Width="50"
                           TextAlignment="Center" />
                <Image Source="{Binding PictureSmall}"
                       Width="50"
                       Height="50"
                       Stretch="UniformToFill"
                       Margin="10,0" />
                <TextBlock Margin="0,5"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="1"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="CompactEventsItemTemplate">
            <Grid Width="100">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="100"
                           Height="70" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}" />
                <Image Source="{Binding Picture}"
                       Width="100"
                       Height="70"
                       Stretch="UniformToFill" />
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding StartDateString}"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           Grid.Row="1"
                           Margin="0,5,0,0"
                           TextAlignment="Center"
                           FontWeight="Bold" />
                <TextBlock Margin="0,5,0,0"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="2"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center"
                           FontWeight="Bold" />
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding VenueName}"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           Grid.Row="3"
                           Margin="0,5,0,0"
                           TextAlignment="Center"
                           FontSize="9.333" />
                <TextBlock TextWrapping="Wrap"
                           Text="{Binding VenueLocation}"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           Grid.Row="4"
                           Margin="0,5"
                           TextAlignment="Center"
                           FontSize="9.333" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="CompactWithPlaycountItemTemplate">
            <Grid Width="100">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Rectangle Fill="{StaticResource TreeViewItemSelectionBorder}"
                           Stroke="{StaticResource ColorAccentBrush}"
                           Width="70"
                           Height="70" />
                <TextBlock TextWrapping="Wrap"
                           Text="No Image"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Foreground="{StaticResource ControlForeground}" />
                <Image Source="{Binding Picture}"
                       Width="70"
                       Height="70"
                       Stretch="UniformToFill" />
                <TextBlock Margin="0,5"
                           TextWrapping="Wrap"
                           d:LayoutOverrides="Width"
                           Text="{Binding Name}"
                           Grid.Row="1"
                           Foreground="{StaticResource ControlForeground}"
                           HorizontalAlignment="Center"
                           TextAlignment="Center"
                           FontWeight="Bold" />
                <toolkit:WrapPanel Grid.Row="2"
                                   d:LayoutOverrides="Width"
                                   HorizontalAlignment="Center">
                    <TextBlock TextWrapping="Wrap"
                               Margin="0,0,5,0"
                               Foreground="{StaticResource ControlForeground}"
                               HorizontalAlignment="Center"
                               Text="Played"
                               FontSize="9.333" />
                    <TextBlock TextWrapping="Wrap"
                               Text="{Binding PlayCountString}"
                               Foreground="{StaticResource ControlForeground}"
                               HorizontalAlignment="Center"
                               Margin="0,0,5,0"
                               FontSize="9.333" />
                    <TextBlock TextWrapping="Wrap"
                               Margin="0,0,5,0"
                               Foreground="{StaticResource ControlForeground}"
                               HorizontalAlignment="Center"
                               Text="times"
                               FontSize="9.333" />
                </toolkit:WrapPanel>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <ctrl:WorkitemControl BusyContext="{Binding CurrentBusyViewModel}"
                          DialogContext="{Binding ActiveDialog}">
        <toolkit:DockPanel Margin="5">
            <StackPanel Orientation="Horizontal"
                        d:LayoutOverrides="Height"
                        toolkit:DockPanel.Dock="Top"
                        Margin="0,0,0,15">
                <TextBlock TextWrapping="Wrap"
                           Text="Detail:"
                           Style="{StaticResource Heading2}"
                           d:LayoutOverrides="Width"
                           Margin="0,0,10,0" />
                <TextBlock x:Name="DisplayName"
                           TextWrapping="Wrap"
                           Style="{StaticResource Heading2}" />
            </StackPanel>
            <Border BorderBrush="{StaticResource ControlBorderBrush}"
                    BorderThickness="1"
                    toolkit:DockPanel.Dock="Bottom"
                    Margin="10,15,10,10"
                    CornerRadius="3"
                    Background="{StaticResource DarkInnerShadowDarkBrush}"
                    Padding="5">
                <Button x:Name="TryClose"
                        Content="Close"
                        HorizontalAlignment="Right" />
            </Border>
            <sdk:TabControl toolkit:DockPanel.Dock="Top"
                            Margin="10,0">
                <sdk:TabItem Header="Information">
                    <ScrollViewer Margin="-5,-4"
                                  Style="{StaticResource CustomScrollViewerStyle}"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <toolkit:DockPanel Margin="5">
                            <Grid toolkit:DockPanel.Dock="Top">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock TextWrapping="Wrap"
                                           Text="Listeners"
                                           Margin="5"
                                           VerticalAlignment="Center"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Streamable"
                                           VerticalAlignment="Center"
                                           Grid.Row="1"
                                           Margin="5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBlock HorizontalAlignment="Left"
                                           TextWrapping="Wrap"
                                           Text="Last.fm-Address"
                                           VerticalAlignment="Center"
                                           Grid.Row="2"
                                           Margin="5"
                                           Foreground="{StaticResource ControlForeground}" />
                                <TextBox Grid.Column="1"
                                         d:LayoutOverrides="Width"
                                         IsReadOnly="True"
                                         Margin="5,2"
                                         Text="{Binding CurrentArtist.ListenersString}" />
                                <TextBox Text="Yes"
                                         d:LayoutOverrides="Width"
                                         Grid.Row="1"
                                         Grid.Column="1"
                                         Margin="5,2"
                                         Visibility="{Binding CurrentArtist.Streamable, Converter={StaticResource visibilityConverter}}"
                                         IsReadOnly="True" />
                                <TextBox Text="No"
                                         Grid.Row="1"
                                         Grid.Column="1"
                                         Margin="5,2"
                                         d:LayoutOverrides="Width"
                                         Visibility="{Binding CurrentArtist.Streamable, Converter={StaticResource visibilityConverter}}"
                                         IsReadOnly="True" />
                                <Border Grid.Column="1"
                                        Margin="5,2"
                                        Grid.Row="2"
                                        d:LayoutOverrides="Width"
                                        CornerRadius="2"
                                        Background="{StaticResource DarkInnerShadowDarkBrush}"
                                        BorderThickness="1"
                                        BorderBrush="{StaticResource DarkBorder}">
                                    <HyperlinkButton Content="{Binding CurrentArtist.UrlString}"
                                                     NavigateUri="{Binding CurrentArtist.Url}"
                                                     HorizontalAlignment="Left"
                                                     Margin="5,6,5,2"
                                                     VerticalAlignment="Center" />
                                </Border>
                                <Rectangle Margin="5,0"
                                           Grid.RowSpan="3"
                                           Stroke="{StaticResource ColorAccentBrush}"
                                           RadiusX="3"
                                           RadiusY="3"
                                           Grid.Column="2"
                                           Width="130"
                                           Height="92"
                                           Fill="{StaticResource TreeViewItemSelectionBorder}" />
                                <TextBlock HorizontalAlignment="Center"
                                           TextWrapping="Wrap"
                                           Text="No Image"
                                           VerticalAlignment="Center"
                                           Foreground="{StaticResource ControlForeground}"
                                           Grid.Column="3"
                                           Grid.RowSpan="3" />
                                <Rectangle Margin="5,0"
                                           Grid.RowSpan="3"
                                           RadiusX="3"
                                           RadiusY="3"
                                           Grid.Column="2"
                                           Width="130"
                                           Height="92"
                                           Cursor="Hand"
                                           Visibility="{Binding CurrentArtist.PictureVisibility, FallbackValue=Collapsed}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="MouseLeftButtonUp">
                                            <cal:ActionMessage MethodName="OpenPicture" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                    <Rectangle.Fill>
                                        <ImageBrush Stretch="UniformToFill"
                                                    ImageSource="{Binding CurrentArtist.Picture}" />
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Grid>
                            <TextBlock TextWrapping="Wrap"
                                       Text="Similar Artists"
                                       toolkit:DockPanel.Dock="Top"
                                       Style="{StaticResource Heading5}"
                                       Margin="5,15,5,5" />
                            <ListBox x:Name="SimilarArtists"
                                     ItemTemplate="{StaticResource CompactItemTemplate}"
                                     ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                                     ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                     Style="{StaticResource InvisibleListBoxStyle}"
                                     toolkit:DockPanel.Dock="Top">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <cal:ActionMessage MethodName="OpenSimilar">
                                            <cal:Parameter Value="{Binding SelectedItem, ElementName=SimilarArtists}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ListBox>
                        </toolkit:DockPanel>
                    </ScrollViewer>
                </sdk:TabItem>
                <sdk:TabItem Header="Biography"
                             d:LayoutOverrides="Width, Height">
                    <ScrollViewer Style="{StaticResource CustomScrollViewerStyle}"
                                  Margin="-5,-4">
                        <StackPanel>
                            <TextBox TextWrapping="Wrap"
                                     Text="{Binding CurrentArtist.Bio.Content}"
                                     IsReadOnly="True"
                                     d:LayoutOverrides="Width, GridBox"
                                     FontWeight="Normal"
                                     VerticalScrollBarVisibility="Disabled" />
                            <TextBlock Text="{Binding CurrentArtist.Bio.Published}"
                                       TextAlignment="Right"
                                       Foreground="{StaticResource ControlForeground}"
                                       d:LayoutOverrides="Width" />
                        </StackPanel>
                    </ScrollViewer>
                </sdk:TabItem>
                <sdk:TabItem Header="Albums">
                    <ListBox x:Name="Albums"
                             ItemTemplate="{StaticResource CompactWithPlaycountItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenAlbum">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=Albums}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
                <sdk:TabItem Header="Tracks">
                    <ListBox x:Name="Tracks"
                             ItemTemplate="{StaticResource CompactWithPlaycountItemTemplate}"
                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                             Margin="-5"
                             Style="{StaticResource InvisibleListBoxStyle}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cal:ActionMessage MethodName="OpenTrack">
                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=Tracks}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ListBox>
                </sdk:TabItem>
                <sdk:TabItem Header="Misc">
                    <ScrollViewer Margin="-5,-4"
                                  BorderBrush="{x:Null}"
                                  Style="{StaticResource CustomScrollViewerStyle}"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <toolkit:DockPanel Margin="5">
                            <toolkit:Accordion HorizontalAlignment="Stretch"
                                               VerticalAlignment="Stretch"
                                               toolkit:DockPanel.Dock="Top">
                                <toolkit:AccordionItem Header="Next Events">
                                    <ListBox x:Name="NextEvents"
                                             ItemTemplate="{StaticResource CompactEventsItemTemplate}"
                                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                             d:LayoutOverrides="Width"
                                             Style="{StaticResource InvisibleListBoxStyle}"
                                             ScrollViewer.VerticalScrollBarVisibility="Visible" />
                                </toolkit:AccordionItem>
                                <toolkit:AccordionItem Header="Most Popular Tags">
                                    <ListBox x:Name="Tags"
                                             ItemTemplate="{StaticResource TagItemTemplate}"
                                             ItemsPanel="{StaticResource WrappingItemsPanelTemplate}"
                                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                             d:LayoutOverrides="Width"
                                             Style="{StaticResource InvisibleListBoxStyle}"
                                             ScrollViewer.VerticalScrollBarVisibility="Visible">
                                        <i:Interaction.Triggers>
                                            <i:EventTrigger EventName="SelectionChanged">
                                                <cal:ActionMessage MethodName="OpenTag">
                                                    <cal:Parameter Value="{Binding SelectedItem, ElementName=Tags}" />
                                                </cal:ActionMessage>
                                            </i:EventTrigger>
                                        </i:Interaction.Triggers>
                                    </ListBox>
                                </toolkit:AccordionItem>
                            </toolkit:Accordion>
                        </toolkit:DockPanel>
                    </ScrollViewer>
                </sdk:TabItem>
            </sdk:TabControl>
        </toolkit:DockPanel>
    </ctrl:WorkitemControl>
</UserControl>
